package com.cheney.demo.thread;

import java.util.concurrent.CountDownLatch;

public class CountDownDemo {

	public static void main(String[] args) throws Exception {
		CountDownLatch count=new CountDownLatch(1);
		new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					System.out.println("sleep ..");
					Thread.sleep(2000);
					count.countDown();
					System.out.println("wake up..");
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}).start();
		
		System.out.println("wait ..");
		
		count.await();
		
		System.out.println("end..");
		
		Thread.sleep(5000);
	}
}
